﻿CREATE PROCEDURE [dbo].[Hogar_Agente_Activar]   
	@AgenteId INT,
	@Activo BIT
AS 
BEGIN

/*****************************************************************************************************************************************/
-- Author: Carlos Mendoza
-- Purpose:   activa/desactiva un agente
/*****************************************************************************************************************************************/ 
	
	UPDATE [dbo].[Agente]
	SET [Activo] = @Activo, [FechaBaja] = CONVERT(varchar(10), GETDATE(),120)
	WHERE [AgenteId] = @AgenteId

	UPDATE [dbo].[Actividad]
	SET [ResponsableId] = NULL
	WHERE [ResponsableId] = @AgenteId

	
END